package laravel.mvc.view.blade.create;

import com.google.common.base.Joiner;
import node.Node;

import java.util.Arrays;
import java.util.List;

import static com.google.common.base.CaseFormat.LOWER_CAMEL;
import static com.google.common.base.CaseFormat.UPPER_CAMEL;

/**
 * Created by thormentor on 28-04-2014.
 */
public abstract class   BladeElement extends Node {
    protected final List<String> args;

    public BladeElement(String... args) {
        super();
        this.args = Arrays.asList(args);
    }

    @Override
    protected String getBegin() {
        return Joiner.on("").skipNulls().join(
                "@",
                UPPER_CAMEL.to(LOWER_CAMEL, getClass().getSimpleName()),
                getArgs()
        );
    }

    protected String getArgs() {
        if (args.size() == 0)
            return null;

        return String.format("('%s')", Joiner.on("', '").join(args));
    }

    @Override
    protected String getEnd() {
        return null;
    }
}
